// 1、存储
export const setItem = (key, value) => {
  if (typeof value === 'object') {
    value = JSON.stringify(value)
  }
  window.localStorage.setItem(key, value)
}
// 2、获取
export const getItem = (key) => {
  try {
    return JSON.parse(window.localStorage.getItem(key))
  } catch {
    return window.localStorage.getItem(key)
  }
}
// 3、删除
export const removeItem = (key) => {
  window.localStorage.removeItem(key)
}
// 4、清空
export const removeAllItem = () => {
  window.localStorage.clear()
}
